<template>
<div>
  <el-form :inline="true" :model="form" size="small">
    <el-form-item label="店铺">
      <el-input v-model="form.name" placeholder="请输入" clearable></el-input>
    </el-form-item>
    <el-form-item label="品牌">
      <el-input v-model="form.folding_restaurant_brand" placeholder="请输入"></el-input>
    </el-form-item>
    <el-form-item label="品类">
      <el-input v-model="form.flavors" placeholder="请输入" clearable></el-input>
    </el-form-item>
    <el-form-item label="是否品牌">
      <el-select v-model="form.is_premium" placeholder="请选择" clearable>
        <el-option label="是" :value="true"></el-option>
        <el-option label="否" :value="false"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="是否新店">
      <el-select v-model="form.is_new" placeholder="请选择" clearable>
        <el-option label="是" :value="true"></el-option>
        <el-option label="否" :value="false"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onQuery">查 询</el-button>
    </el-form-item>
  </el-form>

  <data-table :paged-loader="pagedLoader" max-height="720px" ref="dt">
    <el-table-column prop="name" label="店铺"></el-table-column>
    <el-table-column prop="folding_restaurant_brand" label="品牌"></el-table-column>
    <el-table-column prop="latitude" label="纬度"></el-table-column>
    <el-table-column prop="longitude" label="经度"></el-table-column>
    <el-table-column prop="flavors" label="所属品类">
      <template v-slot="{row}">{{(row.flavors || []).map(v => v.name).join(',')}}</template>
    </el-table-column>
    <el-table-column prop="is_premium" label="是否品牌店">
      <template v-slot="{row}">{{row.is_premium ? '是' : '否'}}</template>
    </el-table-column>
    <el-table-column prop="recent_order_num" label="近期销量" sortable></el-table-column>
    <el-table-column prop="rating" label="评分"></el-table-column>
    <el-table-column prop="rating_count" label="评价总数" sortable></el-table-column>
    <el-table-column prop="is_new" label="是否新店">
      <template v-slot="{row}">{{row.is_new ? '是' : '否'}}</template>
    </el-table-column>
    <el-table-column prop="opening_hours" label="营业时间">
      <template v-slot="{row}">{{(row.opening_hours || []).join(',')}}</template>
    </el-table-column>
    <el-table-column prop="float_minimum_order_amount" label="起送价"></el-table-column>
    <el-table-column prop="delivery_mode.text" label="配送"></el-table-column>
    <el-table-column prop="float_delivery_fee" label="配送费"></el-table-column>
  </data-table>
</div>
</template>

<script lang="ts">
import { Component, Vue, Ref } from 'vue-property-decorator'
import { genPagedLoader } from '@/utils/paged'

@Component
export default class Shops extends Vue {
  @Ref() dt!: any

  pagedLoader = genPagedLoader('/eleme/shops')

  form = {
    name: '',
    folding_restaurant_brand: '',
    flavors: '',
    is_premium: null,
    is_new: null
  }

  onQuery () {
    this.dt.query(this.form)
  }

  mounted () {
    this.dt.query()
  }
}
</script>
